<template>
  <div class="sysname">
    <div class="login_body">
      <div>
        <el-avatar :src="require('../../assets/images/1.jpg')"></el-avatar>
      </div>
      <span class="systitle">医保控费系统</span>
      <div class="h20"></div>
      <div class="input_box">
        <el-input v-model="form.account" placeholder="请输入用户名">
          <el-button slot="prepend" icon="el-icon-user"></el-button>
        </el-input>
      </div>
      <div class="h20"></div>
      <div class="input_box">
        <el-input v-model="form.password" placeholder="请输入密码" show-password>
          <el-button slot="prepend" icon="el-icon-lock"></el-button>
        </el-input>
      </div>
       <div class="h20"></div>
      <div class="input_box">
          <el-button class="btn_login" type="danger" round @click="handleLogin()">登录</el-button>
      </div>
    </div>
  </div>
</template>

<style lang="scss">
body {
  background-color: rgba(0, 146, 230, 0.185);
  margin: 0;
  padding: 0;
}
.sysname {
  position: relative;
  top:20%;

  .systitle {
    color: rgb(114, 195, 233);
    line-height: 40px;
    font-size: 20px;
  }
  .login_body {
    background-color: white;
    margin: 0 auto;
    height: 310px;
    width: 340px;
    padding-top: 20px;
    border-radius: 10px;
    box-shadow: darkgrey 10px 10px 30px 5px;
    text-align: center;

    .shoptype {
      padding-top: 10px;
      margin-bottom: 15px;
    }

    .h20 {
      height: 20px;
    }

    .input_box {
        width: 284px;
        margin: 0 auto;

        .el-form-item {
            margin-bottom: 15px;
        }

        .btn_login {
            width: 100%;
        }
    }
  }
}
</style>

<script>
import { login } from '../../api/permission'
import { mapActions } from 'vuex'

export default {
  data () {
    return {
      form: {
        shoptype: '1',
        account: '',
        password: ''
      }
    }
  },
  methods: {
    ...mapActions({
      LOGIN_IN_HANDLE: 'user/LOGIN_IN_HANDLE'
    }),
    async handleLogin () {
      try {
        const data = await login(this.$data.form.account, this.$data.form.password)
        console.log(data)
        this.LOGIN_IN_HANDLE(data)
        this.$router.replace('/')
      } catch (e) {
        console.log(e)
      }
    }
  }
}
</script>
